﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>SendMode - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The SendMode function causes Send, Click, MouseMove, MouseClick and MouseClickDrag to use the Event or Play mode rather than the default (Input)." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>SendMode</h1>

<p>Makes <a href="Send.htm">Send</a> synonymous with SendEvent or SendPlay rather than the default (SendInput). Also makes Click and MouseMove/Click/Drag use the specified method.</p>

<pre class="Syntax"><span class="func">SendMode</span> Mode</pre>

<h2 id="Parameters">参数</h2>
<dl>
  <dt>Mode</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>Specify one of the following words:</p>
    <p><strong>Event</strong>: Switches to the <a href="Send.htm#SendEvent">SendEvent</a> method for <a href="Send.htm">Send</a>, <a href="Send.htm">SendText</a>, <a href="Click.htm">Click</a>, and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a>.</p>
    <p><strong>Input</strong>: This is the starting default used by all scripts. It uses the <a href="Send.htm#SendInput">SendInput</a> method for <a href="Send.htm">Send</a>, <a href="Send.htm">SendText</a>, <a href="Click.htm">Click</a>, and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a>. Known limitations:</p>
    <ul>
      <li>Windows Explorer ignores SendInput's simulation of certain navigational hotkeys such as <kbd>Alt</kbd>+<kbd>&larr;</kbd>. To work around this, use either <code>SendEvent "!{Left}"</code> or <code>SendInput "{Backspace}"</code>.</li>
    </ul>
    <p><strong>InputThenPlay</strong>: Same as above except that rather than falling back to Event mode when SendInput is <a href="Send.htm#SendInputUnavail">unavailable</a>, it reverts to Play mode (below). This also causes the <a href="Send.htm#SendInput">SendInput function</a> itself to revert to Play mode when SendInput is unavailable.</p>
    <p id="Play"><strong>Play</strong>: Switches to the <a href="Send.htm#SendPlay">SendPlay</a> method for <a href="Send.htm">Send</a>, <a href="Send.htm">SendText</a>, <a href="Click.htm">Click</a>, and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a>.<br>
    Known limitations:</p>
    <ul>
      <li>Characters that do not exist in the current keyboard layout (such as &Ocirc; in English) cannot be sent. To work around this, use <a href="Send.htm#SendEvent">SendEvent</a>.</li>
      <li>Simulated mouse dragging might have no effect in RichEdit controls (and possibly others) such as those of WordPad and Metapad. To use an alternate mode for a particular drag, follow this example: <code><a href="Send.htm#SendEvent">SendEvent</a> "{Click 6, 52, down}{Click 45, 52, up}"</code>.</li>
      <li>Simulated mouse wheel rotation produces movement in only one direction (usually downward, but upward in some applications). Also, wheel rotation might have no effect in applications such as MS Word and Notepad. To use an alternate mode for a particular rotation, follow this example: <code><a href="Send.htm#SendEvent">SendEvent</a> "{WheelDown 5}"</code>.</li>
      <li>When using <code>SendMode "Play"</code> in the auto-execute section (top part of the script), all remapped keys are affected and might lose some of their functionality. See <a href="../misc/Remap.htm#SendPlay">SendPlay remapping limitations</a> for details.</li>
      <li>SendPlay does not trigger AutoHotkey's hotkeys or hotstrings, or global hotkeys registered by other programs or the OS.</li>
    </ul>
  </dd>
</dl>

<h2 id="Remarks">备注</h2>
<p>Since SendMode also changes the mode of <a href="Click.htm">Click</a> and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a>, there may be times when you wish to use a different mode for a particular mouse event. The easiest way to do this is via <a href="Send.htm#Click">{Click}</a>. 例如:</p>
<pre>SendEvent "{Click 100, 200}"  <em>; SendEvent uses the older, traditional method of clicking.</em></pre>
<p>If SendMode is used in the auto-execute section (top part of the script), it also affects <a href="../misc/Remap.htm">keyboard and mouse remapping</a>. In particular, if you use <code>SendMode "Play"</code> with remapping, 请参阅 <a href="../misc/Remap.htm#SendPlay">SendPlay remapping limitations</a>.</p>
<p>The built-in variable <strong>A_SendMode</strong> contains the current setting.</p>
<p>每个新运行的<a href="../misc/Threads.htm">线程</a>(如 <a href="../Hotkeys.htm">热键</a>, <a href="../objects/Menu.htm">自定义菜单项</a>或<a href="SetTimer.htm">定时</a>子程序) 都会以此函数的默认设置开始. 这个默认设置可以通过在脚本的自动执行段(脚本的顶部) 使用此函数来改变.</p>
<h2 id="Related">相关</h2>
<p><a href="Send.htm">Send</a>, <a href="SetKeyDelay.htm">SetKeyDelay</a>, <a href="SetMouseDelay.htm">SetMouseDelay</a>, <a href="Click.htm">Click</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a>, <a href="MouseMove.htm">MouseMove</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>SendMode "Input"
SendMode "InputThenPlay"</pre>
</div>

</body>
</html>